#! *_*coding:utf8*_*

from celery_tasks.main import celery_app
from celery_tasks.sms.yuntongxun.sms import CCP
import logging

logger = logging.getLogger('django')


@celery_app.task(name='send_sms_code')
def send_sms_code(mobile, sms_code, sms_expire, temp_id):

    try:
        result = CCP().send_template_sms(mobile, [sms_code, sms_expire], temp_id)
    except Exception as ret:
        logger.error('发送短信验证码[异常]：[mobile:{}, message:{}]'.format(mobile, ret))
    else:
        if result:
            logger.warning('发送短信验证码[失败]：[mobile:{}]'.format(mobile))
        else:
            logger.info('发送短信验证码[正常]：[mobile:{}]'.format(mobile))
